[Mesa-dev] [PATCH 14/15] virgl: unwrap the includes

Emil Velikov emil.l.velikov at gmail.com
Thu Oct 29 04:59:45 PDT 2015


Include what you want, rather than relying on a header foo.h N levels
down the include chain, to provide something that you need.

Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
---
 src/gallium/drivers/virgl/virgl_buffer.c            |  2 ++
 src/gallium/drivers/virgl/virgl_context.c           |  7 ++-----
 src/gallium/drivers/virgl/virgl_context.h           | 10 ++++------
 src/gallium/drivers/virgl/virgl_encode.c            |  8 ++++++--
 src/gallium/drivers/virgl/virgl_encode.h            | 12 +++++++++++-
 src/gallium/drivers/virgl/virgl_query.c             |  3 ++-
 src/gallium/drivers/virgl/virgl_resource.c          |  3 ++-
 src/gallium/drivers/virgl/virgl_resource.h          |  4 +++-
 src/gallium/drivers/virgl/virgl_screen.c            |  3 ---
 src/gallium/drivers/virgl/virgl_screen.h            |  7 ++-----
 src/gallium/drivers/virgl/virgl_streamout.c         |  3 ++-
 src/gallium/drivers/virgl/virgl_texture.c           |  8 +++++---
 src/gallium/drivers/virgl/virgl_winsys.h            |  5 ++++-
 src/gallium/winsys/virgl/drm/virgl_drm_winsys.c     | 21 +++++++++++++--------
 src/gallium/winsys/virgl/drm/virgl_drm_winsys.h     | 12 ++----------
 src/gallium/winsys/virgl/vtest/virgl_vtest_public.h |  1 +
 src/gallium/winsys/virgl/vtest/virgl_vtest_socket.c |  6 ++++--
 src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c |  7 ++++---
 src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.h |  6 +++---
 19 files changed, 72 insertions(+), 56 deletions(-)

diff --git a/src/gallium/drivers/virgl/virgl_buffer.c b/src/gallium/drivers/virgl/virgl_buffer.c
index 13e8384..ce19fb9 100644
--- a/src/gallium/drivers/virgl/virgl_buffer.c
+++ b/src/gallium/drivers/virgl/virgl_buffer.c
@@ -21,9 +21,11 @@
  * USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 
+#include "util/u_inlines.h"
 #include "util/u_memory.h"
 #include "virgl_context.h"
 #include "virgl_resource.h"
+#include "virgl_screen.h"
 
 static void virgl_buffer_destroy(struct pipe_screen *screen,
                                  struct pipe_resource *buf)
diff --git a/src/gallium/drivers/virgl/virgl_context.c b/src/gallium/drivers/virgl/virgl_context.c
index 32dde06..cae6352 100644
--- a/src/gallium/drivers/virgl/virgl_context.c
+++ b/src/gallium/drivers/virgl/virgl_context.c
@@ -36,19 +36,16 @@
 #include "util/u_upload_mgr.h"
 #include "util/u_blitter.h"
 #include "tgsi/tgsi_text.h"
+#include "indices/u_primconvert.h"
 
 #include "pipebuffer/pb_buffer.h"
 #include "state_tracker/graw.h"
-#include "state_tracker/drm_driver.h"
 
 #include "virgl_encode.h"
-
 #include "virgl_context.h"
-
+#include "virgl_protocol.h"
 #include "virgl_resource.h"
 #include "virgl_screen.h"
-#include "state_tracker/sw_winsys.h"
- struct pipe_screen encscreen;
 
 static uint32_t next_handle;
 uint32_t virgl_object_assign_handle(void)
diff --git a/src/gallium/drivers/virgl/virgl_context.h b/src/gallium/drivers/virgl/virgl_context.h
index 3d8d3ce..adb8ade 100644
--- a/src/gallium/drivers/virgl/virgl_context.h
+++ b/src/gallium/drivers/virgl/virgl_context.h
@@ -25,15 +25,13 @@
 
 #include "pipe/p_state.h"
 #include "pipe/p_context.h"
-#include "virgl_protocol.h"
-
-#include "virgl_screen.h"
 #include "util/u_slab.h"
 #include "util/list.h"
-#include "indices/u_primconvert.h"
 
-struct virgl_resource;
-struct virgl_buffer;
+struct pipe_screen;
+struct tgsi_token;
+struct u_upload_mgr;
+struct virgl_cmd_buf;
 
 struct virgl_sampler_view {
    struct pipe_sampler_view base;
diff --git a/src/gallium/drivers/virgl/virgl_encode.c b/src/gallium/drivers/virgl/virgl_encode.c
index 4493c3f..22fb529 100644
--- a/src/gallium/drivers/virgl/virgl_encode.c
+++ b/src/gallium/drivers/virgl/virgl_encode.c
@@ -25,11 +25,15 @@
 #include "util/u_memory.h"
 #include "util/u_math.h"
 #include "pipe/p_state.h"
-#include "virgl_encode.h"
-#include "virgl_resource.h"
 #include "tgsi/tgsi_dump.h"
 #include "tgsi/tgsi_parse.h"
 
+#include "virgl_context.h"
+#include "virgl_encode.h"
+#include "virgl_protocol.h"
+#include "virgl_resource.h"
+#include "virgl_screen.h"
+
 static int virgl_encoder_write_cmd_dword(struct virgl_context *ctx,
                                         uint32_t dword)
 {
diff --git a/src/gallium/drivers/virgl/virgl_encode.h b/src/gallium/drivers/virgl/virgl_encode.h
index d792369..030bcd6 100644
--- a/src/gallium/drivers/virgl/virgl_encode.h
+++ b/src/gallium/drivers/virgl/virgl_encode.h
@@ -23,7 +23,17 @@
 #ifndef VIRGL_ENCODE_H
 #define VIRGL_ENCODE_H
 
-#include "virgl_context.h"
+#include "pipe/p_defines.h"
+#include "pipe/p_state.h"
+
+#include "virgl_winsys.h"
+
+struct tgsi_token;
+
+struct virgl_context;
+struct virgl_resource;
+struct virgl_sampler_view;
+
 struct virgl_surface {
    struct pipe_surface base;
    uint32_t handle;
diff --git a/src/gallium/drivers/virgl/virgl_query.c b/src/gallium/drivers/virgl/virgl_query.c
index b06635b..b020055 100644
--- a/src/gallium/drivers/virgl/virgl_query.c
+++ b/src/gallium/drivers/virgl/virgl_query.c
@@ -23,9 +23,10 @@
 
 #include "util/u_memory.h"
 #include "util/u_inlines.h"
-#include "virgl_resource.h"
 #include "virgl_context.h"
 #include "virgl_encode.h"
+#include "virgl_protocol.h"
+#include "virgl_resource.h"
 
 struct virgl_query {
    uint32_t handle;
diff --git a/src/gallium/drivers/virgl/virgl_resource.c b/src/gallium/drivers/virgl/virgl_resource.c
index 52425f4..0b2fc4e 100644
--- a/src/gallium/drivers/virgl/virgl_resource.c
+++ b/src/gallium/drivers/virgl/virgl_resource.c
@@ -21,8 +21,9 @@
  * USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 #include "util/u_inlines.h"
-#include "virgl_resource.h"
 #include "virgl_context.h"
+#include "virgl_resource.h"
+#include "virgl_screen.h"
 
 bool virgl_res_needs_flush_wait(struct virgl_context *vctx,
                                 struct virgl_resource *res,
diff --git a/src/gallium/drivers/virgl/virgl_resource.h b/src/gallium/drivers/virgl/virgl_resource.h
index cae8321..bab9bcb 100644
--- a/src/gallium/drivers/virgl/virgl_resource.h
+++ b/src/gallium/drivers/virgl/virgl_resource.h
@@ -24,7 +24,7 @@
 #ifndef VIRGL_RESOURCE_H
 #define VIRGL_RESOURCE_H
 
-#include "util/u_inlines.h"
+#include "util/u_resource.h"
 #include "util/u_range.h"
 #include "util/list.h"
 #include "util/u_transfer.h"
@@ -32,8 +32,10 @@
 #include "virgl_hw.h"
 #define VR_MAX_TEXTURE_2D_LEVELS 15
 
+struct winsys_handle;
 struct virgl_screen;
 struct virgl_context;
+
 struct virgl_resource {
    struct u_resource u;
    struct virgl_hw_res *hw_res;
diff --git a/src/gallium/drivers/virgl/virgl_screen.c b/src/gallium/drivers/virgl/virgl_screen.c
index 38bff4a..cca379d 100644
--- a/src/gallium/drivers/virgl/virgl_screen.c
+++ b/src/gallium/drivers/virgl/virgl_screen.c
@@ -28,10 +28,7 @@
 #include "pipe/p_defines.h"
 #include "pipe/p_screen.h"
 #include "draw/draw_context.h"
-#include "vl/vl_decoder.h"
-#include "vl/vl_video_buffer.h"
 
-#include "state_tracker/sw_winsys.h"
 #include "tgsi/tgsi_exec.h"
 
 #include "virgl_screen.h"
diff --git a/src/gallium/drivers/virgl/virgl_screen.h b/src/gallium/drivers/virgl/virgl_screen.h
index 1a24eec..52e72ca 100644
--- a/src/gallium/drivers/virgl/virgl_screen.h
+++ b/src/gallium/drivers/virgl/virgl_screen.h
@@ -23,12 +23,9 @@
 #ifndef VIRGL_H
 #define VIRGL_H
 
-#include "util/u_transfer.h"
-
-#include "virgl_hw.h"
-
-#include "virgl_winsys.h"
 #include "pipe/p_screen.h"
+#include "virgl_winsys.h"
+
 struct virgl_screen {
    struct pipe_screen base;
    struct virgl_winsys *vws;
diff --git a/src/gallium/drivers/virgl/virgl_streamout.c b/src/gallium/drivers/virgl/virgl_streamout.c
index c449010..b6a65ff 100644
--- a/src/gallium/drivers/virgl/virgl_streamout.c
+++ b/src/gallium/drivers/virgl/virgl_streamout.c
@@ -20,10 +20,11 @@
  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  * USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
-#include "util/u_memory.h"
 #include "util/u_inlines.h"
+#include "util/u_memory.h"
 #include "virgl_context.h"
 #include "virgl_encode.h"
+#include "virgl_protocol.h"
 #include "virgl_resource.h"
 
 static struct pipe_stream_output_target *virgl_create_so_target(
diff --git a/src/gallium/drivers/virgl/virgl_texture.c b/src/gallium/drivers/virgl/virgl_texture.c
index ebc4755..3118962 100644
--- a/src/gallium/drivers/virgl/virgl_texture.c
+++ b/src/gallium/drivers/virgl/virgl_texture.c
@@ -20,11 +20,13 @@
  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  * USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
-#include "util/u_memory.h"
 #include "util/u_format.h"
-#include "virgl_screen.h"
-#include "virgl_resource.h"
+#include "util/u_inlines.h"
+#include "util/u_memory.h"
+
 #include "virgl_context.h"
+#include "virgl_resource.h"
+#include "virgl_screen.h"
 
 static void virgl_copy_region_with_blit(struct pipe_context *pipe,
                                         struct pipe_resource *dst,
diff --git a/src/gallium/drivers/virgl/virgl_winsys.h b/src/gallium/drivers/virgl/virgl_winsys.h
index 76d401b..ea21f2b 100644
--- a/src/gallium/drivers/virgl/virgl_winsys.h
+++ b/src/gallium/drivers/virgl/virgl_winsys.h
@@ -23,8 +23,11 @@
 #ifndef VIRGL_WINSYS_H
 #define VIRGL_WINSYS_H
 
-#include "pipe/p_compiler.h"
+#include "pipe/p_defines.h"
+#include "virgl_hw.h"
 
+struct pipe_box;
+struct pipe_fence_handle;
 struct winsys_handle;
 struct virgl_hw_res;
 
diff --git a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c
index 0616de3..c9cdf68 100644
--- a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c
+++ b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c
@@ -20,21 +20,26 @@
  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  * USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
-#include "virgl_drm_winsys.h"
-#include "virgl_drm_public.h"
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <sys/ioctl.h>
+
+#include "os/os_mman.h"
+#include "os/os_time.h"
 #include "util/u_memory.h"
 #include "util/u_format.h"
+#include "util/u_hash_table.h"
+#include "util/u_inlines.h"
 #include "state_tracker/drm_driver.h"
 
-#include "os/os_mman.h"
-#include "os/os_time.h"
-#include <sys/ioctl.h>
-#include <errno.h>
 #include <xf86drm.h>
-#include <fcntl.h>
-#include <stdio.h>
 #include "virtgpu_drm.h"
 
+#include "virgl_drm_winsys.h"
+#include "virgl_drm_public.h"
+
 static inline boolean can_cache_resource(struct virgl_hw_res *res)
 {
    return res->cacheable == TRUE;
diff --git a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.h b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.h
index c835272..da85ff8 100644
--- a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.h
+++ b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.h
@@ -24,22 +24,14 @@
 #define VIRGL_DRM_WINSYS_H
 
 #include <stdint.h>
-#include "pipe/p_compiler.h"
-#include "drm.h"
-
 #include "os/os_thread.h"
+#include "pipe/p_state.h"
 #include "util/list.h"
-#include "util/u_inlines.h"
-#include "util/u_hash_table.h"
-
-#include "pipe/p_screen.h"
-#include "pipe/p_context.h"
-#include "pipe/p_context.h"
 
-#include "virgl/virgl_hw.h"
 #include "virgl/virgl_winsys.h"
 
 struct pipe_fence_handle;
+struct util_hash_table;
 
 struct virgl_hw_res {
    struct pipe_reference reference;
diff --git a/src/gallium/winsys/virgl/vtest/virgl_vtest_public.h b/src/gallium/winsys/virgl/vtest/virgl_vtest_public.h
index 7233649..47379d9 100644
--- a/src/gallium/winsys/virgl/vtest/virgl_vtest_public.h
+++ b/src/gallium/winsys/virgl/vtest/virgl_vtest_public.h
@@ -24,6 +24,7 @@
 #define VIRGL_VTEST_PUBLIC_H
 
 struct virgl_winsys;
+struct sw_winsys;
 
 struct virgl_winsys *virgl_vtest_winsys_wrap(struct sw_winsys *sws);
 
diff --git a/src/gallium/winsys/virgl/vtest/virgl_vtest_socket.c b/src/gallium/winsys/virgl/vtest/virgl_vtest_socket.c
index 8fd6a51..e334753 100644
--- a/src/gallium/winsys/virgl/vtest/virgl_vtest_socket.c
+++ b/src/gallium/winsys/virgl/vtest/virgl_vtest_socket.c
@@ -20,8 +20,7 @@
  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  * USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
-#include "virgl_vtest_winsys.h"
-#include "virgl_vtest_public.h"
+
 #include <sys/socket.h>
 #include <errno.h>
 #include <stdio.h>
@@ -34,6 +33,9 @@
 /* connect to remote socket */
 #define VTEST_SOCKET_NAME "/tmp/.virgl_test"
 
+#include "virgl_vtest_winsys.h"
+#include "virgl_vtest_public.h"
+
 /* block read/write routines */
 static int virgl_block_write(int fd, void *buf, int size)
 {
diff --git a/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c b/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c
index 28c4c62..6181d7c 100644
--- a/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c
+++ b/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c
@@ -21,13 +21,14 @@
  * USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 #include <stdio.h>
-#include "virgl_vtest_winsys.h"
-#include "virgl_vtest_public.h"
 #include "util/u_memory.h"
 #include "util/u_format.h"
 #include "util/u_inlines.h"
-#include "state_tracker/drm_driver.h"
 #include "os/os_time.h"
+#include "state_tracker/sw_winsys.h"
+
+#include "virgl_vtest_winsys.h"
+#include "virgl_vtest_public.h"
 
 static void *virgl_vtest_resource_map(struct virgl_winsys *vws, struct virgl_hw_res *res);
 static void virgl_vtest_resource_unmap(struct virgl_winsys *vws, struct virgl_hw_res *res);
diff --git a/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.h b/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.h
index fd8cb7a..72ca2b2 100644
--- a/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.h
+++ b/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.h
@@ -27,15 +27,15 @@
 #include "pipe/p_compiler.h"
 #include "pipe/p_defines.h"
 #include "pipe/p_state.h"
-#include "state_tracker/sw_winsys.h"
-#include "virgl/virgl_hw.h"
-#include "virgl/virgl_winsys.h"
 #include "util/list.h"
 #include "os/os_thread.h"
 
+#include "virgl/virgl_winsys.h"
 #include "vtest_protocol.h"
 
 struct pipe_fence_handle;
+struct sw_winsys;
+struct sw_displaytarget;
 
 struct virgl_vtest_winsys {
    struct virgl_winsys base;
-- 
2.6.2



More information about the mesa-dev mailing list