[Mesa-dev] [PATCH 15/16] radeonsi: prepare for driver-specific driconf options

Nicolai Hähnle nhaehnle at gmail.com
Fri Jun 30 12:45:56 UTC 2017


From: Nicolai Hähnle <nicolai.haehnle at amd.com>

---
 src/gallium/Automake.inc                           |  2 ++
 .../auxiliary/pipe-loader/pipe_loader_drm.c        |  2 +-
 src/gallium/auxiliary/target-helpers/drm_helper.h  | 25 ++++++++++++++++++++++
 .../auxiliary/target-helpers/drm_helper_public.h   |  2 ++
 src/gallium/drivers/radeonsi/Makefile.am           | 13 +++++++++++
 src/gallium/drivers/radeonsi/Makefile.sources      |  4 ++++
 src/gallium/drivers/radeonsi/driinfo_radeonsi.h    |  1 +
 src/gallium/targets/pipe-loader/Makefile.am        |  1 +
 src/gallium/targets/pipe-loader/pipe_radeonsi.c    |  9 ++++++++
 9 files changed, 58 insertions(+), 1 deletion(-)
 create mode 100644 src/gallium/drivers/radeonsi/driinfo_radeonsi.h

diff --git a/src/gallium/Automake.inc b/src/gallium/Automake.inc
index 48b5a44..3e21aa7 100644
--- a/src/gallium/Automake.inc
+++ b/src/gallium/Automake.inc
@@ -32,20 +32,22 @@ GALLIUM_DRIVER_CXXFLAGS = \
 	$(VISIBILITY_CXXFLAGS)
 
 GALLIUM_TARGET_CFLAGS = \
 	-I$(top_srcdir)/src \
 	-I$(top_srcdir)/include \
 	-I$(top_srcdir)/src/loader \
 	-I$(top_srcdir)/src/gallium/include \
 	-I$(top_srcdir)/src/gallium/auxiliary \
 	-I$(top_srcdir)/src/gallium/drivers \
 	-I$(top_srcdir)/src/gallium/winsys \
+	-I$(top_builddir)/src/util/ \
+	-I$(top_builddir)/src/gallium/drivers/ \
 	$(DEFINES) \
 	$(PTHREAD_CFLAGS) \
 	$(LIBDRM_CFLAGS) \
 	$(VISIBILITY_CFLAGS)
 
 GALLIUM_COMMON_LIB_DEPS = \
 	-lm \
 	$(LIBUNWIND_LIBS) \
 	$(LIBSENSORS_LIBS) \
 	$(CLOCK_LIB) \
diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
index d8d3878..69a0283 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
@@ -81,21 +81,21 @@ static const struct drm_driver_descriptor driver_descriptors[] = {
         .configuration = pipe_default_configuration_query,
     },
     {
         .driver_name = "r600",
         .create_screen = pipe_r600_create_screen,
         .configuration = pipe_default_configuration_query,
     },
     {
         .driver_name = "radeonsi",
         .create_screen = pipe_radeonsi_create_screen,
-        .configuration = pipe_default_configuration_query,
+        .configuration = pipe_radeonsi_configuration_query,
     },
     {
         .driver_name = "vmwgfx",
         .create_screen = pipe_vmwgfx_create_screen,
         .configuration = pipe_default_configuration_query,
     },
     {
         .driver_name = "kgsl",
         .create_screen = pipe_freedreno_create_screen,
         .configuration = pipe_default_configuration_query,
diff --git a/src/gallium/auxiliary/target-helpers/drm_helper.h b/src/gallium/auxiliary/target-helpers/drm_helper.h
index a4fcde3..95b4a27 100644
--- a/src/gallium/auxiliary/target-helpers/drm_helper.h
+++ b/src/gallium/auxiliary/target-helpers/drm_helper.h
@@ -1,17 +1,18 @@
 #ifndef DRM_HELPER_H
 #define DRM_HELPER_H
 
 #include <stdio.h>
 #include "target-helpers/inline_debug_helper.h"
 #include "target-helpers/drm_helper_public.h"
 #include "state_tracker/drm_driver.h"
+#include "util/xmlpool.h"
 
 static const struct drm_conf_ret throttle_ret = {
    .type = DRM_CONF_INT,
    .val.val_int = 2,
 };
 
 static const struct drm_conf_ret share_fd_ret = {
    .type = DRM_CONF_BOOL,
    .val.val_bool = true,
 };
@@ -168,29 +169,53 @@ pipe_radeonsi_create_screen(int fd, const struct pipe_screen_config *config)
 
    /* First, try amdgpu. */
    rw = amdgpu_winsys_create(fd, config, radeonsi_screen_create);
 
    if (!rw)
       rw = radeon_drm_winsys_create(fd, config, radeonsi_screen_create);
 
    return rw ? debug_screen_wrap(rw->screen) : NULL;
 }
 
+const struct drm_conf_ret *
+pipe_radeonsi_configuration_query(enum drm_conf conf)
+{
+   static const struct drm_conf_ret xml_options_ret = {
+      .type = DRM_CONF_POINTER,
+      .val.val_pointer =
+#include "radeonsi/si_driinfo.h"
+   };
+
+   switch (conf) {
+   case DRM_CONF_XML_OPTIONS:
+      return &xml_options_ret;
+   default:
+      break;
+   }
+   return pipe_default_configuration_query(conf);
+}
+
 #else
 
 struct pipe_screen *
 pipe_radeonsi_create_screen(int fd, const struct pipe_screen_config *config)
 {
    fprintf(stderr, "radeonsi: driver missing\n");
    return NULL;
 }
 
+const struct drm_conf_ret *
+pipe_radeonsi_configuration_query(enum drm_conf conf)
+{
+   return NULL;
+}
+
 #endif
 
 #ifdef GALLIUM_VMWGFX
 #include "svga/drm/svga_drm_public.h"
 #include "svga/svga_public.h"
 
 struct pipe_screen *
 pipe_vmwgfx_create_screen(int fd, const struct pipe_screen_config *config)
 {
    struct svga_winsys_screen *sws;
diff --git a/src/gallium/auxiliary/target-helpers/drm_helper_public.h b/src/gallium/auxiliary/target-helpers/drm_helper_public.h
index c540d7c..4681913 100644
--- a/src/gallium/auxiliary/target-helpers/drm_helper_public.h
+++ b/src/gallium/auxiliary/target-helpers/drm_helper_public.h
@@ -17,20 +17,22 @@ struct pipe_screen *
 pipe_nouveau_create_screen(int fd, const struct pipe_screen_config *config);
 
 struct pipe_screen *
 pipe_r300_create_screen(int fd, const struct pipe_screen_config *config);
 
 struct pipe_screen *
 pipe_r600_create_screen(int fd, const struct pipe_screen_config *config);
 
 struct pipe_screen *
 pipe_radeonsi_create_screen(int fd, const struct pipe_screen_config *config);
+const struct drm_conf_ret *
+pipe_radeonsi_configuration_query(enum drm_conf conf);
 
 struct pipe_screen *
 pipe_vmwgfx_create_screen(int fd, const struct pipe_screen_config *config);
 
 struct pipe_screen *
 pipe_freedreno_create_screen(int fd, const struct pipe_screen_config *config);
 
 struct pipe_screen *
 pipe_virgl_create_screen(int fd, const struct pipe_screen_config *config);
 
diff --git a/src/gallium/drivers/radeonsi/Makefile.am b/src/gallium/drivers/radeonsi/Makefile.am
index 2d5c1a3..c99a7ca 100644
--- a/src/gallium/drivers/radeonsi/Makefile.am
+++ b/src/gallium/drivers/radeonsi/Makefile.am
@@ -26,10 +26,23 @@ include $(top_srcdir)/src/gallium/Automake.inc
 AM_CFLAGS = \
 	$(GALLIUM_DRIVER_CFLAGS) \
 	-I$(top_builddir)/src/amd/common \
 	-I$(top_srcdir)/src/amd/common \
 	$(RADEON_CFLAGS) \
 	$(LLVM_CFLAGS)
 
 noinst_LTLIBRARIES = libradeonsi.la
 
 libradeonsi_la_SOURCES = $(C_SOURCES)
+
+GEN_DRIINFO_INPUTS = \
+	$(top_srcdir)/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h \
+	$(srcdir)/driinfo_radeonsi.h
+
+PYTHON_GEN = $(AM_V_GEN)$(PYTHON2) $(PYTHON_FLAGS)
+MERGE_DRIINFO = $(top_srcdir)/src/util/merge_driinfo.py
+
+si_driinfo.h: $(MERGE_DRIINFO) $(GEN_DRIINFO_INPUTS)
+	$(PYTHON_GEN) $(MERGE_DRIINFO) $(GEN_DRIINFO_INPUTS) > $@ || ($(RM) $@; false)
+
+BUILT_SOURCES = $(GENERATED_SOURCES)
+CLEANFILES = $(GENERATED_SOURCES)
diff --git a/src/gallium/drivers/radeonsi/Makefile.sources b/src/gallium/drivers/radeonsi/Makefile.sources
index 626fe6f..c443e6e 100644
--- a/src/gallium/drivers/radeonsi/Makefile.sources
+++ b/src/gallium/drivers/radeonsi/Makefile.sources
@@ -1,11 +1,15 @@
+GENERATED_SOURCES := \
+	si_driinfo.h
+
 C_SOURCES := \
+	$(GENERATED_SOURCES) \
 	cik_sdma.c \
 	si_blit.c \
 	si_compute.c \
 	si_compute.h \
 	si_cp_dma.c \
 	si_debug.c \
 	si_descriptors.c \
 	si_dma.c \
 	si_hw_context.c \
 	si_pipe.c \
diff --git a/src/gallium/drivers/radeonsi/driinfo_radeonsi.h b/src/gallium/drivers/radeonsi/driinfo_radeonsi.h
new file mode 100644
index 0000000..a358f02
--- /dev/null
+++ b/src/gallium/drivers/radeonsi/driinfo_radeonsi.h
@@ -0,0 +1 @@
+// DriConf options specific to radeonsi
diff --git a/src/gallium/targets/pipe-loader/Makefile.am b/src/gallium/targets/pipe-loader/Makefile.am
index 6b11618..400b198 100644
--- a/src/gallium/targets/pipe-loader/Makefile.am
+++ b/src/gallium/targets/pipe-loader/Makefile.am
@@ -20,20 +20,21 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 # DEALINGS IN THE SOFTWARE.
 
 include $(top_srcdir)/src/gallium/Automake.inc
 
 AM_CPPFLAGS = \
 	$(GALLIUM_CFLAGS) \
 	-I$(top_srcdir)/include \
 	-I$(top_srcdir)/src/gallium/drivers \
 	-I$(top_srcdir)/src/gallium/winsys \
+	-I$(top_builddir)/src/util \
 	$(GALLIUM_PIPE_LOADER_DEFINES) \
 	$(LIBDRM_CFLAGS) \
 	$(VISIBILITY_CFLAGS) \
 	-DGALLIUM_RBUG \
 	-DGALLIUM_TRACE
 
 pipedir = $(libdir)/gallium-pipe
 pipe_LTLIBRARIES =
 
 PIPE_LIBS =
diff --git a/src/gallium/targets/pipe-loader/pipe_radeonsi.c b/src/gallium/targets/pipe-loader/pipe_radeonsi.c
index 598baf5..2d33d0e 100644
--- a/src/gallium/targets/pipe-loader/pipe_radeonsi.c
+++ b/src/gallium/targets/pipe-loader/pipe_radeonsi.c
@@ -1,16 +1,17 @@
 #include "state_tracker/drm_driver.h"
 #include "target-helpers/inline_debug_helper.h"
 #include "radeon/drm/radeon_drm_public.h"
 #include "radeon/radeon_winsys.h"
 #include "amdgpu/drm/amdgpu_public.h"
 #include "radeonsi/si_public.h"
+#include "util/xmlpool.h"
 
 static struct pipe_screen *
 create_screen(int fd, const struct pipe_screen_config *config)
 {
    struct radeon_winsys *rw;
 
    /* First, try amdgpu. */
    rw = amdgpu_winsys_create(fd, flags, radeonsi_screen_create);
 
    if (!rw)
@@ -24,23 +25,31 @@ static const struct drm_conf_ret throttle_ret = {
    .val.val_int = 2,
 };
 
 static const struct drm_conf_ret share_fd_ret = {
    .type = DRM_CONF_BOOL,
    .val.val_bool = true,
 };
 
 static const struct drm_conf_ret *drm_configuration(enum drm_conf conf)
 {
+   static const struct drm_conf_ret xml_options_ret = {
+      .type = DRM_CONF_POINTER,
+      .val.val_pointer =
+#include "radeonsi/si_driinfo.h"
+   };
+
    switch (conf) {
    case DRM_CONF_THROTTLE:
       return &throttle_ret;
    case DRM_CONF_SHARE_FD:
       return &share_fd_ret;
+   case DRM_CONF_XML_OPTIONS:
+      return &xml_options_ret;
    default:
       break;
    }
    return NULL;
 }
 
 PUBLIC
 DRM_DRIVER_DESCRIPTOR("radeonsi", create_screen, drm_configuration)
-- 
2.9.3



More information about the mesa-dev mailing list